﻿using AutoMapper;
using J.Status.Application.Command.RoomTypeCommand;
using J.StatusModel;
using MediatR;
using StatusService;

namespace J.Status.Application.Handler.RoomTypeHandler
{
    public class RoomTypeUpdateHandler : IRequestHandler<RoomTypeUpdateCommand, int>
    {
        private readonly IMapper mapper;
        private readonly IRoomTypeService roomTypeService;
        public RoomTypeUpdateHandler(IMapper mapper, IRoomTypeService roomTypeService)
        {
            this.mapper = mapper;
            this.roomTypeService = roomTypeService;
        }

        public async Task<int> Handle(RoomTypeUpdateCommand request, CancellationToken cancellationToken)
        {
            RoomTypeModel model = mapper.Map<RoomTypeModel>(request);
            return await roomTypeService.UpdateRoomType(model);
        }
    }
}
